function [] = imitateOrders(CON)

global impOrderPr
global moOrder
global sigmaOrder
global typeOfDistr
global SimplePuassLambda
global lambdaNonPuass
global moComposition
global sigmaComposition

%global connectorPath
%global host
%global port
%global dbname
%global user
%global password
%global usingBD


if (typeOfDistr ~= 0)
    switch typeOfDistr
        case 1
            N = abs(ceil(normrnd(moOrder,sigmaOrder,[1 1])));
        case 2 
            N = abs(ceil(poissrnd(SimplePuassLambda,1)));
        case 3
            N = abs(ceil((poissrnd(lambdaNonPuass(1),1) + poissrnd(lambdaNonPuass(2),1) + lambdaNonPuass(param1(2),1))/3));
    end;
    if (N == 0) N = 1; end;
    [good1, good2, good3] = generateComposition(moComposition,sigmaComposition,N);
    priority = binornd(1,impOrderPr,[1 N]);
    
javaaddpath(CON.connectorPath) 
driver = 'com.mysql.jdbc.Driver';
url = ['jdbc:mysql://' CON.host ':' num2str(CON.port) '/' CON.dbname];
conn = database(CON.dbname, CON.user, CON.password, driver, url);
if isconnection(conn) 
    qry = strcat('use ',usingDB,';');
    exec(conn, qry);
    if (cell2mat((get(fetch(exec(conn, 'select count(Id) from Order_')),'Data'))) ~= 0)
        orderId = cell2mat(get(fetch(exec(conn, 'select max(Id) from Order_')),'Data'));
    else orderId = 0;
    end;
    
    tact = cell2mat(get(fetch(exec(conn, 'select CurrentDay from ManufacturingInit;')),'Data'));
    tactsForSimpleOrder = cell2mat(get(fetch(exec(conn, 'select TactsForSimpleOrder from ManufacturingInit;')),'Data'));
    tactsForExpressOrder = cell2mat(get(fetch(exec(conn, 'select TactsForExpressOrder from ManufacturingInit;')),'Data'));
    for i=1:N
        if (good1(i) ~= 0) 
            for j=1:good1(i)
            exec(conn,strcat('insert into OrderProductTable(OrderId,ProductId,StateOrderProductId,orderHistoryId) values(', num2str(orderId+i), ',1,0,0); '));
            end;
        end;
        if (good2(i) ~= 0) 
            for j=1:good2(i)
            exec(conn,strcat('insert into OrderProductTable(OrderId,ProductId,StateOrderProductId,orderHistoryId) values(',  num2str(orderId+i), ',2,0,0); '));
            end;
        end;
        if (good3(i) ~= 0) 
            for j=1:good3(i)
            exec(conn,strcat('insert into OrderProductTable(OrderId,ProductId,StateOrderProductId,orderHistoryId) values(', num2str(orderId+i), ',3,0,0); '));
            end;
        end;
        if (priority(i) == 0) 
            endTact = tact +tactsForSimpleOrder;
        else endTact = tact + tactsForExpressOrder;
        end;
        
        exec(conn,strcat('insert into Order_(id,OrderStateId,BeginDate,ExpectedEndDate,Priority,totalSum) values(', num2str(orderId+i), ',0,', num2str(tact),',', num2str(endTact),',', num2str(priority(i)),',',num2str(good1(i)+good2(i)+good3(i)),');'));
    end;
    close(conn);
end
end


end